package cn.gzsf.sboot09;

public class IndParamDemo {

    public static void main(String[] args) {
        //请1+2
        //1+2+3
        //1+,,,,+10
        //int sum = sum(1,2);
        int sum = sum(1,2);
        System.out.println(sum);
    }
  /*  public static int sum(int  a,int b){
        return a+b;
    }
    public static int sum(int  a,int b,int c){
        return a+b+c;
    }*/
    //int...num 这种写法是不定参数，本质就是一个数组，可以接收任意多个类型为int的数
    public static int sum(int ... num){
        int sum = 0;
        for(int n:num){
            sum+=n;
        }
        return sum;
    }

}
